import Vue from 'vue'

/**
 * 初始化全局公用实例，前后端同步
 * 同步采样Vuex,因为这个是自动同步的
 * 客户端在Vuex之后在添加其他数据存储策略
 */
export default (ctx) => {
  let store = null
  if (process.browser) {
    const stores = []
    stores.push(new VuexStore(ctx.store))
    stores.push(new CookieStore())
    store = new MixStore(stores)
  } else {
    store = new VuexStore(ctx.store)
  }

  Vue.prototype.$ds = store
  ctx.$ds = store
  ctx.store.$ds = store
}
